<%@ page language="java" contentType="text/html; charset=UTF-8"
         isELIgnored="false" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib uri="/mytag" prefix="yjd"%>
<body>
<div class="wrap">
    <div class="h_a">搜索</div>
    <form id="merchant_ops_form" action="${requestScope.FPWEB.rootPath }/settlement/day/detail/list${requestScope.FPWEB.urlStuff}"  method="get" autocomplete="off">
        <div class="search_type cc">
            <label>商户：</label>
            <select name="org_id" id="org_id" class="mr10">
                <option value="">全部商户</option>
                <c:forEach items="${orgids }" var="item">
                    <option ${item.key==maps.org_id?"selected='selected'":"" } value="${item.key }">${item.value }</option>
                </c:forEach>
            </select>
            <label>资金渠道：</label>
            <select name="fund_channel" id="fund_channel" class="mr10">
                <option value="">全部渠道</option>
                <c:forEach items="${fundChannelList }" var="item">
                    <option ${item.key==maps.fund_channel?"selected='selected'":"" } value="${item.key }">${item.desc }</option>
                </c:forEach>
            </select>
            <label>结算日期：</label>
            <input id="startDate" name="startDate" type="text" class="input length_1 mr10 J_date" value="${maps.startDate}"> &nbsp;-- &nbsp;
            <input id="endDate" name="endDate" type="text" class="input length_1 mr10 J_date" value="${maps.endDate}">
            <button type="submit" class="btn btn_submit mr10 J_ajax_submit_btn length_1" onclick="on_search()">搜索</button>
            <button type="submit" class="btn btn_submit mr10 J_ajax_submit_btn length_2" onclick="return on_generate()">生成日结算明细</button>
        </div>
    </form>
    <div class="table_list">
        <table width="100%">
            <thead>
            <tr>
                <td>机构名称</td>
                <td>资金渠道</td>
                <td>订单ID</td>
                <td>用户ID</td>
                <td>类型</td>
                <td>借贷标志</td>
                <td>订单状态</td>
                <td>结算日期</td>
                <td>结算金额</td>
                <td>首付金额</td>
                <td>贷款金额</td>
                <td>订单总额</td>
                <td>生成时间</td>
            </tr>
            </thead>
            <tbody id="J_word_list">
            <c:forEach items="${pager.pagerModel.dataList }" var="item" >
                <tr>
                    <td>
                        <input name="org_id" hidden="hidden" value="${item.org_id}" >
                        ${item.strMap.org_name}
                    </td>
                    <td>${item.strMap.channel_name}</td>
                    <td>${item.order_id}</td>
                    <td>${item.user_id}</td>
                    <td><c:if test="${item.type==1}">订单</c:if><c:if test="${item.type==2}">退单</c:if></td>
                    <td><c:if test="${item.flag==1}">收入</c:if><c:if test="${item.flag==0}">未知</c:if><c:if test="${item.flag==-1}">支出</c:if></td>
                    <td>${item.strMap.status}</td>
                    <td>${item.clear_date}</td>
                    <td>${item.clear_price}</td>
                    <td>${item.payment}</td>
                    <td>${item.loan_amount}</td>
                    <td>${item.order_price}</td>
                    <td>${item.strMap.create_time}</td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <!-- 分页 -->
        <%@ include file="../public/pager/pager.pagination.jsp" %>
    </div>
</div>
<script>
    YJD.use('AppAdminCommon');

    function on_search() {
        $('#merchant_ops_form').attr('action', '<yjd:url url="/settlement/day/detail/list"/>');
    };

    function on_generate() {
        $('#merchant_ops_form').attr('action', '<yjd:url url="/settlement/day/detail/generate"/>');

        var start = $('#startDate').val();
        if(start == null || start == ""){
            start = "开始";
        }
        var end = $('#endDate').val();
        if(end == null || end == ""){
            end = "今";
        }
        return confirm("确定需要重新生成从" + start + "至"+ end +"的日结算明细吗？");
    };

</script>
</body>